<?php
class Default_Form_Login extends Zend_Form{
    public function init(){
        $this->setName("default");    
        $this->setAction('auth/login');                 
        
        $username = new Zend_Form_Element_Text('username');
        $username->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidators(array( 
                                        array('NotEmpty',true,array('messages' => 'Username không được để trống')) )) ;
        $username->setAttrib('class','form-control')->setAttrib('placeholder','Tên đăng nhập');
        $username->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');
        
        $password = new Zend_Form_Element_Password('password');
        $password->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty',true,array('messages' => 'Password không được để trống'));
        $password ->setAttrib('class','form-control')->setAttrib('placeholder','Mật khẩu');        
        $password->removeDecorator('dtddwrapper')->removeDecorator('HtmlTag')->removeDecorator('Label');
                         
        // submit button
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('class','btn btn-primary')->setLabel('Login');
        $submit->setAttribs(array('style' => 'float:left;'));        
        $this->setDecorators(array(
                               array('viewScript',
                               array('viewScript'=>'template/form_login.phtml'),
                        )));          
        // add elements to form
        $this->addElements(array (
            $username, $password, $submit            
        ));
    }
}

